package com.basic;

import java.util.Scanner;

public class CloseLight {
	static int[][] press = new int[6][8];
	
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int[][] a = new int[6][7];
		for(int i = 1;i < 6;i++)
			for(int j = 1;j<7;j++)
			{
				a[i][j] = scanner.nextInt();
			}
		scanner.close();
		compare(a);
		
		for(int i = 1;i < 6;i++)
		{
			for(int j = 1;j < 7;j++)
			{
				System.out.print(press[i][j] + " ");
			}
			System.out.println();
		}
	}
	
	public static boolean guess(int[][] a) {
		for(int i = 2;i<=5;i++)
		{
			for(int j = 1;j <= 6;j++)
			{
				press[i][j] = (press[i-1][j-1] 
							  +press[i-1][j+1]
							  +press[i-2][j]
							  +press[i-1][j]
							  +a[i-1][j])%2;
			}
		}
		for(int j = 1;j <= 6;j++)
		{
			if(a[5][j] != (press[5][j-1] + press[5][j+1] + press[4][j] + press[5][j])%2)
				return false;
		}
		return true;
	}
	
	public static void compare(int[][] a) {
		while(!guess(a))
		{
			press[1][1]++;
			int c = 1;
			while(press[1][c]>1)
			{
				press[1][c] = 0;
				c++;
			press[1][c]++;
			}
		}
		
	}
}
